<template>
  <div class="order">
    <div class="list">
      <div class="cartCount">
        <div
          v-if="orderInfo.merName"
          class="storeInfo acea-row"
          @click="goMerchant(orderInfo)"
        >
          <span class="mr10 iconfont icon-shangjiadingdan"></span>
          <div class="name mr10">{{ orderInfo.merName }}</div>
          <span class="iconfont icon-gengduo" style="font-size: 10px"></span>
        </div>
        <div class="cartInfo">
          <div
            class="item"
            v-for="(item, indexn) in cartInfo"
            :key="indexn"
            @click="goShopDetail(item)"
          >
            <div class="acea-row row-between-wrapper">
              <div class="txtPic acea-row row-middle">
                <div class="pictrue">
                  <el-image
                    class="img"
                    :src="item.image"
                    fit="scale-down"
                  ></el-image>
                </div>
                <div class="text">
                  <div class="name line2">
                    {{ item.productName ? item.productName : item.storeName }}
                  </div>
                  <div class="acea-row row-middle mat20">
                    <div class="info" v-if="item.sku">
                      {{ filterText(item.sku) }}
                    </div>
                    <div>
                      <span class="money">
                        <statistic
                          :value="item.price"
                          :currency="item.currency"
                        />
                      </span>
                      <span class="num">x{{ item.payNum }}</span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { goMerchant, goShopDetail } from "@/utils/order.js";
export default {
  name: "orderGoods",
  props: {
    cartInfo: {
      type: Array,
      default: function () {
        return [];
      },
    },
    orderInfo: {
      type: Object,
      default: function () {
        return {};
      },
    },
  },
  data() {
    return {
      currency: this.$store.state.currency,
    };
  },
  methods: {
    goMerchant(item) {
      goMerchant(item.merId, this);
    },
    goShopDetail(item) {
      goShopDetail(item.productId, this);
    },
    // 暂时过滤规格和默认两个汉字
    filterText(str) {
      if (str === "规格") {
        return this.$t("page.users.goodsCommentList.attribute");
      } else if (str === "默认") {
        return this.$t("page.goodsSearch.Default");
      } else {
        return str;
      }
    },
  },
};
</script>

<style scoped lang="scss">
@import "@/assets/css/variables.scss";
.list {
  background-color: #fff;
}
.cartInfo {
  padding: 30px;
  border-radius: 8px;
}
.cartCount {
  margin-bottom: 15px;
  border-radius: 8px;
}
.storeInfo {
  width: 100%;
  height: 76px;
  line-height: 76px;
  padding: 0 30px;
  border-bottom: 1px dashed #cecece;
  font-size: 16px;
  color: $use-color-info;
  cursor: pointer;
}
.order {
  margin: 0 auto;

  .list {
    .item:last-child {
      margin-bottom: 0;
    }
    .item {
      margin-bottom: 24px;
      cursor: pointer;

      .txtPic {
        color: $use-color-info;
        font-size: 16px;
        .pictrue {
          width: 100px;
          height: 100px;
          position: relative;
          .img {
            width: 100%;
            height: 100%;
            border-radius: 8px;
            border: 1px solid $use-color-line;
          }
        }

        .text {
          flex: 1;
          margin-left: 16px;
          .name {
            width: 100%;
          }

          .info {
            // margin-top: 10px;
            // color: #999999;
            width: 250px;
          }
        }
      }

      .money {
        font-size: 16px;
        ::v-deep .statistic {
          color: $use-color-info;
        }
      }

      .num {
        margin-left: 6px;
      }
    }
  }
}
</style>
